﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace WatchForChanges
{
    class Program
    {
        private static FileSystemWatcher watcher;

        static void Main(string[] args)
        {
            var path = @"C:\Users\Ken\Documents\Mind Chemistry\SolutionFramework\SolutionFramework\";

            watcher = new FileSystemWatcher(path, "*.cs");

            watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
            watcher.IncludeSubdirectories = true;
            watcher.EnableRaisingEvents = true;

            watcher.Changed += (sender, e) =>
            {
                var file = new FileInfo(e.FullPath);

                if (file.Exists)
                {
                    Console.WriteLine(e.Name + " " + Enum.GetName(typeof(WatcherChangeTypes), e.ChangeType) + ", FileSize=" + file.Length.ToString());
                }
            };

            Console.ReadKey();
        }
    }
}
